#include <QtGui/QApplication>
#include "mainwindow.h"
// #include <QSplashScreen>
 #include <QTranslator>
 #include <QLocale>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QIcon icon;
    QPixmap pixmap(":/images/image/splash.png");
    QSplashScreen splash(pixmap);
     splash.show();
    a.processEvents();
    QDir dir;
    QString h=dir.homePath();

    if (!dir.exists(h+"/.kirtasse")) //التاكد من وجود مجلد المكتبة
    {
        dir.mkdir( h+"/.kirtasse");
    }
    if (!dir.exists(h+"/.kirtasse/data")) //التاكد من وجود مجلد البياات
    {
        dir.mkdir( h+"/.kirtasse/data");
    }
    if (!dir.exists(h+"/.kirtasse/books")) //التاكد من وجود مجلد الكتاب
    {
        dir.mkdir( h+"/.kirtasse/books");
    }
    QFile file;

    if (!file.exists(h+"/.kirtasse/data/group.xml")){
        file.copy(QCoreApplication::applicationDirPath() +"/data/group.xml",h +"/.kirtasse/data/group.xml");
    }



    QString translatorFileName = QLatin1String("qt_");
    translatorFileName += QLocale::system().name();
    QTranslator *translator = new QTranslator(&a);
    if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
        a.installTranslator(translator);

    icon.addPixmap(QPixmap(QString::fromUtf8(":/images/image/groupbook.png")), QIcon::Normal, QIcon::Off);
    a.setWindowIcon(icon);
    MainWindow w;
    w.show();
    splash.finish(&w);
    return a.exec();
}
